<div class="sm-pop">
    <div id="dialog_form" class="layui-form">

        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i> 活动名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required" maxlength="250" placeholder="请输入活动名称" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>活动简介</label>
            <div class="layui-input-block">
                <textarea id="ID_vote_brief" cols="20" rows="5"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i>活动规则</label>
            <div class="layui-input-block">
                <textarea id="ID_vote_rules" cols="20" rows="5"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i> 报名时间</label>
            <div class="layui-inline layui-input-time">
                <input type="text" class="layui-input laydate" lay-verify="required" id="start1" name="signUpStartTime">
                <i class="iconfont icon-rili"></i>
            </div>
            <span class="layui-inline font-primary">-</span>
            <div class="layui-inline layui-input-time">
                <input type="text" class="layui-input laydate" lay-verify="required" id="end1" name="signUpEndTime">
                <i class="iconfont icon-rili"></i>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i> 投票时间</label>
            <div class="layui-inline layui-input-time">
                <input type="text" class="layui-input laydate" lay-verify="required" id="start2" name="voteStartTime">
                <i class="iconfont icon-rili"></i>
            </div>
            <span class="layui-inline font-primary">-</span>
            <div class="layui-inline layui-input-time">
                <input type="text" class="layui-input laydate" lay-verify="required" id="end2" name="voteEndTime">
                <i class="iconfont icon-rili"></i>
            </div>
        </div>

        <fieldset class="layui-elem-field layui-field-title">
            <legend><i style="color: red">*</i> 活动海报 <span class="must">(必填)</span></legend>
        </fieldset>
        <div class="layui-form-item">
            <input type="hidden" lay-verify="required" name="poster">
            <div class="layui-upload-drag" id="uploader">
                <i class="layui-icon"></i>
                <p>点击上传，或将文件拖拽到此处</p>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remark" maxlength="200" placeholder="请输入备注" class="layui-textarea"></textarea>
            </div>
        </div>

    </div>
</div>

<script>
    layui.use(['layedit', "upload", "form","laydate"], function () {
        var layedit = layui.layedit;
        var laydate = layui.laydate;
        var $ = layui.$;
        var form = layui.form;
        var upload = layui.upload;
        form.render();

        laydate.render({
            elem: '#start1',
            done: function (value, date, endDate) {
                var end = $("#end1").val();
                if (value && end && (new Date(end) - new Date(value)) <= 0) {
                    $("#start1").val("");
                    layer.msg("开始时间需小于结束时间");
                }
            }
        });
        laydate.render({
            elem: '#end1',
            done: function (value, date, endDate) {
                var start = $("#start1").val();
                if (value && start && (new Date(value) - new Date(start)) <= 0) {
                    $("#end1").val("");
                    layer.msg("结束时间需大于开始时间");
                }
            }
        });
        laydate.render({
            elem: '#start2',
            done: function (value, date, endDate) {
                var end = $("#end2").val();
                if (value && end && (new Date(end) - new Date(value)) <= 0) {
                    $("#start2").val("");
                    layer.msg("开始时间需小于结束时间");
                }
            }
        });
        laydate.render({
            elem: '#end2',
            done: function (value, date, endDate) {
                var start = $("#start2").val();
                if (value && start && (new Date(value) - new Date(start)) <= 0) {
                    $("#end2").val("");
                    layer.msg("结束时间需大于开始时间");
                }
            }
        });

        //单图
        upload.render({
            elem: '#uploader',
            url: '/managerImg/uploadFileImg',
            size: 5120,//KB,0或默认不限制
            done: function (result, index, upload) {
                if (result.success && result.data) {
                    $("#uploader").html("<img src='" + result.data + "' style='width: 200px;height:200px;'/><p>点击重新上传，或将文件拖拽到此处</p>");
                    $("#dialog_form input[name=poster]").val(result.data);
                } else {
                    layer.msg('上传失败');
                }
            }
        });

    });
</script>

